package com.yc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.entity.Pmap;
import com.yc.mapper.PmapMapper;
import com.yc.service.IPmapService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * InnoDB free: 4096 kB 服务实现类
 * </p>
 *
 * @author ly
 * @since 2022-05-25
 */
@Service
public class PmapServiceImpl extends ServiceImpl<PmapMapper, Pmap> implements IPmapService {
    @Resource
    private PmapMapper pmapMapper;

    @Override
    public List< Pmap > queryByCtid(Integer ctid) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("ctid",ctid);
        return pmapMapper.selectList(queryWrapper);
    }

    @Override
    public Integer addPmap(List< Pmap > list) {
        Integer flag=-1;
        for ( Pmap pmap :list ) {
            flag=pmapMapper.insert(pmap);
            if(flag!=1){
                break;
            }
        }
        return flag;
    }

    @Override
    public Integer update(List< Pmap > list) {
        Integer flag=-1;
        for ( Pmap pmap :list ) {
            flag=pmapMapper.updateById(pmap);
            if ( flag!=1 ){
                break;
            }
        }
        return flag;
    }
}
